package com.leyou.order.client;

import com.leyou.order.dto.AddressDTO;

import java.util.ArrayList;
import java.util.List;

public abstract class AddressClient {

    public static  final List<AddressDTO> addressList = new ArrayList<AddressDTO>(){
        {
            AddressDTO addressDTO = new AddressDTO();
            addressDTO.setId(1L);
            addressDTO.setAddress("东门大桥212号");
            addressDTO.setCity("成都");
            addressDTO.setDistrict("锦江区");
            addressDTO.setName("牛哥");
            addressDTO.setPhone("13736521478");
            addressDTO.setState("四川");
            addressDTO.setZipCode("610000");
            addressDTO.setIsDefault(true);
            add(addressDTO);


            AddressDTO addressDTO2 = new AddressDTO();
            addressDTO2.setId(2L);
            addressDTO2.setAddress("天府大道212号");
            addressDTO2.setCity("成都");
            addressDTO2.setDistrict("高新区");
            addressDTO2.setName("张哥");
            addressDTO2.setPhone("13836521478");
            addressDTO2.setState("四川");
            addressDTO2.setZipCode("610000");
            addressDTO2.setIsDefault(false);
            add(addressDTO2);
        }
    };

    public  static  AddressDTO findById(Long id){
        for (AddressDTO addressDTO : addressList) {
            if(addressDTO.getId() == id) return  addressDTO;
        }
        return  null;
    }
}
